package org.balthie.cal.impl.cmd;

import java.util.Deque;

import org.balthie.cal.common.spec.AbstractSpecification;
import org.balthie.cal.core.AbsCommand;
import org.balthie.cal.core.ICommand;
import org.balthie.cal.core.IControllor;
import org.balthie.cal.impl.cmd.spec.CmdSizeSpecs;

/**
 * @author：balthie@126.com
 * @createtime ： 2023年3月7日 下午1:37:55
 * @description 输出传入的文本，调试用
 * @since version 初始于版本 0.0.1-SNAPSHOT
 */
public class UndoCmd extends AbsCommand implements IControllor {

	@SuppressWarnings("unchecked")
	public UndoCmd() {
		super("回退");
		// 指令集暂存区不为空才能回退	
		legalSpecs = AbstractSpecification.EMPTY_SPEC.not(CmdSizeSpecs.EMPTY); 
	}

	@Override
	public void execute(Deque<ICommand> workArea, Deque<ICommand> undoArea) {
		// 将指令从暂存区移入 回退区
		ICommand pollLast = workArea.pollLast();
		undoArea.add(pollLast);
	}

	@Override
	public boolean isCompleted(Deque<ICommand> deque) {
		//不参与计算式	
		return Boolean.FALSE;
	}
	
	@Override
	public String getLiterally() {
		return "undo";
	}

	@Override
	public String getTips() {
		return "回退";
	}
	
	
}
